package param

import (
	"bp/internal/util"
	"context"
	"time"
)

type ListCommonParam struct {
	PagerPtr *util.Pager
	BrandID  int64
	EmpID    int64
	MemberID int64
}

func GenListCommonParamFromContext(ctx context.Context) (cPtr *ListCommonParam) {
	cPtr = &ListCommonParam{}
	var pagerPtr *util.Pager
	val := ctx.Value(util.PagerKey{})
	if val == nil {
		pagerPtr = &util.Pager{
			Ts:     time.Now(),
			Offset: 0,
			Limit:  10,
		}
	} else {
		pagerPtr = val.(*util.Pager)
	}
	cPtr.PagerPtr = pagerPtr

	val = ctx.Value(util.BilinTokenKey{})
	if val != nil {
		bToken := val.(*util.BilinToken)
		cPtr.BrandID = bToken.BrandID
		cPtr.EmpID = bToken.EmpID
	}
	val = ctx.Value(util.AuthorizationTokenKey{})
	if val != nil {
		aToken := val.(*util.AuthorizationToken)
		cPtr.BrandID = aToken.BrandID
		cPtr.MemberID = aToken.MemberID
	}

	return
}

type ItemCategoryConfiguration struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type ItemCategoryConfigurationPtrArray []*ItemCategoryConfiguration

type EntityIDToItemCategoryConfigurationPtrsMap = map[int64]ItemCategoryConfigurationPtrArray

type ItemConfiguration struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type ItemConfigurationPtrArray []*ItemConfiguration

type EntityIDToItemConfigurationPtrsMap = map[int64]ItemConfigurationPtrArray

type ItemID int64

type EntityIDToItemIDMap = map[int64][]ItemID

